package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.admin.SetmealService;
import com.sky.vo.DishItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
//处理小程序端有关套餐的请求
@RestController("userSetmealController")
@RequestMapping("/user/setmeal")
@Slf4j
public class SetmealController {

    @Autowired
    private SetmealService setmealService;
    /**
     * 获取指定分类id的套餐列表
     * @param categoryId
     * @return
     */
    @GetMapping("/list")
    public Result<List<Setmeal>> list(long categoryId){
        log.info("获取指定分类id的套餐列表:{}",categoryId);
        List<Setmeal> list = setmealService.findSetmealByCategoryId(categoryId);
        return Result.success(list);
    }

    @GetMapping("/dish/{id}")
    public Result<List<DishItemVO>> getDishBySetmealId(@PathVariable long id){
        log.info("根据套餐id查询套餐的菜品:{}",id);
        List<DishItemVO> list = setmealService.findDishBySetmealId(id);
        return Result.success(list);
    }
}
